package com.coursehub.exercise.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
import java.util.Objects;

/**
 * 学生题目答案复合主键
 */
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Embeddable
public class StudentQuestionAnswerId implements Serializable {
    
    @Column(name = "user_id", length = 100)
    private String userId;
    
    @Column(name = "exercise_id", length = 100)
    private String exerciseId;
    
    @Column(name = "question_id", length = 100)
    private String questionId;
    
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        StudentQuestionAnswerId that = (StudentQuestionAnswerId) o;
        return Objects.equals(userId, that.userId) && 
               Objects.equals(exerciseId, that.exerciseId) && 
               Objects.equals(questionId, that.questionId);
    }
    
    @Override
    public int hashCode() {
        return Objects.hash(userId, exerciseId, questionId);
    }
}